package cn.mysocketnet.a06tcpdemo2;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    public static void main(String[] args) {
        try(ServerSocket ss = new ServerSocket(10001)){
            Socket socket = ss.accept();
            InputStream is = socket.getInputStream();
            InputStreamReader isr = new InputStreamReader(is);
            BufferedReader br = new BufferedReader(isr);
            // String line;
            // while ((line=br.readLine())!=null){
            //     System.out.println(line);
            // }
            int b;
            while ((b = br.read()) != -1){
                System.out.print((char) b);
            }

        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
